﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate.Dialect;
using NHibernate.SqlCommand;

namespace Apollo
{
    public class MsSql2008NoLockDialect : MsSql2008Dialect
    {
        public MsSql2008NoLockDialect() : base() { }

        public bool SupportsNoLockSelect { get { return true; } }

        //public override SqlString GetLimitString(SqlString querySqlString, int offset, int limit, int? offsetParameterIndex, int? limitParameterIndex)
        //{
        //    SqlString noLockQueryString = base.GetLimitString(querySqlString, offset, limit, offsetParameterIndex, limitParameterIndex);

        //    int indexOfFirstJoin = noLockQueryString.IndexOfCaseInsensitive("left outer join");
        //    if (indexOfFirstJoin > 0)
        //    {
        //        SqlString firstPart = noLockQueryString.Substring(0, indexOfFirstJoin);
        //        SqlString lastPart = noLockQueryString.Substring(indexOfFirstJoin);

        //        noLockQueryString = firstPart
        //            .Append(" with(nolock) ")
        //            .Append(lastPart);
        //    }

        //    noLockQueryString = noLockQueryString.Replace(" on ", " with(nolock) on ");

        //    return noLockQueryString;
        //}

    }

    
}
